home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / EngineCore.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-21  |  4.5 KB  |  157 lines

  1.  
  2. #ifndef __ENGINECORE_H_
  3. #define __ENGINECORE_H_
  4. /*
  5. Peon - Win32 Games Programming Library
  6. Copyright (C) 2002-2005 Erik Yuzwa
  7.  
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12.  
  13. This library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. Library General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Library General Public
  19. License along with this library; if not, write to the Free
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  
  22. Erik Yuzwa
  23. peon AT wazooinc DOT com
  24. */
  25.  
  26. #include "ISingleton.h"
  27. #include "Timer.h"
  28. #include "SceneRenderer.h"
  29. #include "AudioEngine.h"
  30. #include "InputEngine.h"
  31. #include "IApplication.h"
  32.  
  33. namespace peon
  34. {
  35.     /**
  36.     * This is our main entry object for the Peon library
  37.     *
  38.     * This object is responsible for kicking off a main window
  39.     * that we can draw to, along with a lot of the core subsystems
  40.     * involved in the engine.
  41.     */
  42.     class PEONMAIN_API EngineCore : ISingleton<EngineCore>
  43.     {
  44.     public:
  45.         /** Handle to our IniConfigReader instance  */
  46.         IniConfigReader*    m_pConfig;
  47.  
  48.         /** Handle to our IApplication instance */
  49.         IApplication*       m_pApplication;
  50.  
  51.         /** Handle to our Renderer instance for rendering scene geometry */
  52.         SceneRenderer*        m_pVideoDevice;
  53.  
  54.         /** Our Timer object which encapsulates some system time calls */
  55.         Timer                m_oTimer;
  56.  
  57.         /** The frames per second of our rendering loop */
  58.         float                m_fps;
  59.  
  60.         
  61.  
  62.     protected:
  63.         /**
  64.         * This method is responsible for updating the frame rate counter
  65.         */
  66.         void updateFPS();
  67.  
  68.     public:
  69.         /**
  70.         * Constructor
  71.         */
  72.         EngineCore();
  73.  
  74.         /**
  75.         * Destructor
  76.         */
  77.         ~EngineCore();
  78.  
  79.         /** Override standard Singleton retrieval.
  80.         @remarks
  81.         Why do we do this? Well, it's because the Singleton
  82.         implementation is in a .h file, which means it gets compiled
  83.         into anybody who includes it. This is needed for the
  84.         Singleton template to work, but we actually only want it
  85.         compiled into the implementation of the class based on the
  86.         Singleton, not all of them. If we don't change this, we get
  87.         link errors when trying to use the Singleton-based class from
  88.         an outside dll.
  89.         @par
  90.         This method just delegates to the template version anyway,
  91.         but the implementation stays in this single compilation unit,
  92.         preventing link errors.
  93.         */
  94.         static EngineCore& getSingleton(void);
  95.         /** Override standard Singleton retrieval.
  96.         @remarks
  97.         Why do we do this? Well, it's because the Singleton
  98.         implementation is in a .h file, which means it gets compiled
  99.         into anybody who includes it. This is needed for the
  100.         Singleton template to work, but we actually only want it
  101.         compiled into the implementation of the class based on the
  102.         Singleton, not all of them. If we don't change this, we get
  103.         link errors when trying to use the Singleton-based class from
  104.         an outside dll.
  105.         @par
  106.         This method just delegates to the template version anyway,
  107.         but the implementation stays in this single compilation unit,
  108.         preventing link errors.
  109.         */
  110.         static EngineCore* getSingletonPtr(void);
  111.  
  112.         /**
  113.         * This method loads and initializes the subsystems of the 
  114.         * Peon library...audio, video, input and network
  115.         * @param strWindowTitle - our window title
  116.         * @param strIniConfig - path to the INI Configuration information
  117.         * @return bool - false if anything failed
  118.         */
  119.         bool loadEngine( const String& strWindowTitle, const String& strIniConfig );
  120.  
  121.         /**
  122.         * This method unloads and frees up every allocated subsystem
  123.         */
  124.         void unloadEngine();
  125.  
  126.         /**
  127.         * This puts the Peon engine into an endless cycle. Our "main loop"
  128.         * for the game.
  129.         * @return int - negative value if anything went wrong
  130.         */
  131.         int runEngine();
  132.  
  133.         /**
  134.         * This 
  135.         * @return bool - 
  136.         */
  137.         bool setApplication( IApplication* pApplication );
  138.  
  139.         /**
  140.         * This method is just an accessor for our SceneRenderer instance
  141.         * @return SceneRenderer* - our renderer
  142.         */
  143.         SceneRenderer* getRenderer(){ return m_pVideoDevice; }
  144.  
  145.         /**
  146.         * This method is an accessor to grab the IApplication instance
  147.         * IApplication* - our IApplication instance
  148.         */
  149.         IApplication* getApplication(){ return m_pApplication; }
  150.  
  151.  
  152.     };
  153. }
  154.  
  155. #endif
  156.  
  157.